﻿Namespace DotNetNuke.Modules.ActiveForums
    Public Class UserRolesDictionary
        Friend Shared Function GetRoles(ByVal key As String) As String
            Try
                Dim obj As Object = DataCache.CacheRetrieve("afuserroles")
                If Not obj Is Nothing Then
                    Dim dict As Dictionary(Of String, String) = CType(obj, Dictionary(Of String, String))
                    If dict.ContainsKey(key) Then
                        Return dict.Item(key)
                    Else
                        Return String.Empty
                    End If
                Else
                    Return String.Empty
                End If
            Catch ex As Exception
                Return String.Empty
            End Try
        End Function
        Friend Shared Function AddRoles(ByVal key As String, ByVal v As String) As Boolean
            Try
                Dim obj As Object = DataCache.CacheRetrieve("afuserroles")
                Dim dict As Dictionary(Of String, String) = Nothing
                If obj Is Nothing Then
                    dict = New Dictionary(Of String, String)
                Else
                    dict = CType(obj, Dictionary(Of String, String))
                End If
                If dict.ContainsKey(key) Then
                    dict.Item(key) = v
                Else
                    dict.Add(key, v)
                End If
                DataCache.CacheStore("afuserroles", dict, Date.Now.AddMinutes(3))
                Return True
            Catch ex As Exception
                Return False
            End Try

        End Function
    End Class
End Namespace

